# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rdiscount
_gemname=rdiscount
pkgver=2.2.7.2
pkgrel=0
pkgdesc="Fast Implementation of Gruber's Markdown in C"
url="https://dafoster.net/projects/rdiscount/"
arch="all"
license="BSD-3-Clause"
checkdepends="perl ruby-test-unit tidyhtml"
makedepends="ruby-dev ruby-rake"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/davidfstr/$_gemname/archive/$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

build() {
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	install -D -m 755 bin/$_gemname "$pkgdir"/usr/bin/$_gemname

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver

	install -D -m644 man/$_gemname.1 -t "$pkgdir"/usr/share/man/man1/
	install -D -m644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/

	# Remove unnecessary files and rubbish...
	rm -r ext/ lib/*.so man/ test/ COPYING Rakefile BUILDING README* || true
}

sha512sums="
d1a6113d822d1c1a947a4fb72644e082d75fa22c92ff9851074a82f4eb33404cee8dc09f0b41324bdbebab39b8d16ae2569cef04ccd176b3414c16dcf514f2bd  ruby-rdiscount-2.2.7.2.tar.gz
3c053ee8c555a25c156fa0f2bd1d8e553d277dab1f07c32cbf4ba9149886e5455409ad301619f3714c8bfafb952a452d71d81f0a2008b79d778e01c3190691b5  gemspec.patch
"
